"""
Pymodbus Exceptions
--------------------

Custom exceptions to be used in the Modbus code.
"""

class eDIP43AException(Exception):
    ''' Base modbus exception '''

    def __init__(self, string):
        ''' Initialize the exception
        :param string: The message to append to the error
        '''
        self.string = string

    def __str__(self):
        return 'Modbus Error: %s' % self.string

class eDIP43AIOException(eDIP43AException):
    ''' Error resulting from data i/o '''

    def __init__(self, string=""):
        ''' Initialize the exception
        :param string: The message to append to the error
        '''
        message = "[Input/Output] %s" % string
        eDIP43AException.__init__(self, message)

class ParameterException(eDIP43AException):
    ''' Error resulting from invalid paramater '''

    def __init__(self, string=""):
        ''' Initialize the exception
        :param string: The message to append to the error
        '''
        message = "[Invalid Paramter] %s" % string
        eDIP43AException.__init__(self, message)

class NotImplementedException(eDIP43AException):
    ''' Error resulting from not implemented function '''

    def __init__(self, string=""):
        ''' Initialize the exception
        :param string: The message to append to the error
        '''
        message = "[Not Implemented] %s" % string
        eDIP43AException.__init__(self, message)

class ConnectionException(eDIP43AException):
    ''' Error resulting from a bad connection '''

    def __init__(self, string=""):
        ''' Initialize the exception
        :param string: The message to append to the error
        '''
        message = "[Connection] %s" % string
        eDIP43AException.__init__(self, message)